<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<c:set value="${pageContext.request.contextPath}" var="path"
	scope="page" />
<link rel="stylesheet" type="text/css"
	href="${path}/bootstrap-3.3.5-dist/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css"
	href="${path}/bootstrap-3.3.5-dist/dist/css/dataTables.bootstrap.css">
<link rel="stylesheet" type="text/css" href="${path}/css/dispatch.css">
</head>
<style type="text/css">
</style>

<body style="background-color: #ecf0f5; color: #333;">
	<nav class="navbar navbar-static-top" role="navigation"
		style="background: #00a65a"> <!-- Sidebar toggle button-->
	<div class="navbar-custom-menu"
		style="float: right; margin-right: 10px;">
		<ul class="nav navbar-nav">
			<li class="dropdown user user-menu"><a href="#"
				class="dropdown-toggle" data-toggle="dropdown"> <img
					src="images/user_img.jpg" class="user-image" alt="User Image">
					<span class="hidden-xs">wbm</span>
			</a>
				<ul class="dropdown-menu">
					<li class="user-header"><img src="${path}/images/user_img.jpg"
						class="img-circle" alt="User Image">
						<p>
							wbm <small></small>
						</p></li>
					<!-- Menu Footer-->
					<li class="user-footer">
						<div class="pull-left">
							<a href="#" class="btn btn-default btn-flat">个人资料</a>
						</div>
						<div class="pull-right">
							<a href="logout" class="btn btn-default btn-flat">注销</a>
						</div>
					</li>
				</ul></li>
		</ul>
	</div>
	</nav>
	<div class="content">
		<section class="content-header">
		<h2>配送请求列表</h2>
		</section>
		<div class="box box-solid">
			<form id="form1" action="" method="get" class="form form-inline"
				style="padding: 10px 0px;">
				<input type="hidden" id="tab" name="tab" value="0"> <label>订单ID：
					<input type="text" class="form-control" placeholder="请输入订单ID"
					id="activityId" name="activityId" value="">
				</label> <label>订单名称： <input type="text" class="form-control"
					placeholder="请输入订单名称" id="activityName" name="activityName"
					value="">
				</label> <input type="submit" class="btn btn-default" value="搜索">
			</form>
		</div>
		<div class="box box-solid box-body tabContent" id="dispatchTableBox">
			<table class="table table-bordered table-hover table-condensed"
				id="dispatchTable">
				<thead>
					<tr>
						<th>配送请求ID</th>
						<th>配送请求发起时间</th>
						<th>费用</th>
						<th>联系人</th>
						<th>联系人电话</th>
						<th>派送单状态</th>
						<th>操作</th>
						<th>确认</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${orderList }" var="d" varStatus="status">
							<tr>
							 	<td class="dispatch_${d.oId }">${d.oId }</td>
								<td class="dispatch_${d.oId }">${d.oDate }</td>
								<td class="dispatch_${d.oId }">${d.oFeetype }</td>
								<td class="dispatch_${d.oId }">${d.receiver.rName }</td>
								<td class="dispatch_${d.oId }">${d.receiver.rPhone}</td>
								<td class="dispatch_${d.oId }" data-val="${d.oStatus }">${d.oStatus }</td>
								<td data-id="dispatch_${d.oId }">
								<select id="dispatch_${d.oId }">
								<c:forEach items="${subInv }" var="s">
									<option value="${s.sId }">${s.sName }</option>
								</c:forEach>
									<!-- <option value="4">test</option> -->
								</select>
								</td>
								<td class="dispatch_${status.count%2}">
							 		<a data-href="createDispatherForm.action?oId=${d.oId }" data-id="${d.oId }" onclick=comfirmDispatch(this)>确认</a>
								</td>
							</tr>
							
						
					</c:forEach>
				</tbody>
			</table>
		</div>
	</div>
	<div class="modal" id="update_info">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">×</span>
					</button>
					<h4 class="modal-title">修改派送单</h4>
				</div>
				<div class="modal-body">
					<form id="resourceForm">
						<div class="form-group row">
							<label class="col-sm-2" for="">联系人</label>
							<div class="col-sm-10" id="name">
								<label> <input name="dispatch_0" type="text" value="">
								</label>
							</div>
						</div>
						<div class="form-group row">
							<label class="col-sm-2" for="">联系电话</label>
							<div class="col-sm-10" id="name">
								<label> <input name="dispatch_1" type="text" value="">
								</label>
							</div>
						</div>
						<div class="form-group row">
							<label class="col-sm-2" for=""> 收货地址</label>
							<div class="col-sm-10" id="name">
								<label> <input name="dispatch_2" type="text" value="">
								</label>
							</div>
						</div>
						<div class="form-group row">
							<label class="col-sm-2" for="">订单id</label>
							<div class="col-sm-10" id="name">
								<label> <input name="dispatch_3" type="text" value="">
								</label>
							</div>
						</div>
						<div class="form-group row">
							<label class="col-sm-2" for="">派送状态</label>
							<div class="col-sm-10" id="name">
								<div class="col-sm-10" id="">
									<label> <input name="dispatch_5" type="radio" value="1" />未发送
									</label> <label> <input name="dispatch_5" type="radio"
										value="2" />已发送
									</label> <label> <input name="dispatch_5" type="radio"
										value="3" />已接受
									</label>
								</div>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" onclick="">提交</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>

</body>

<script type="text/javascript"
	src="${path}/jquery-3.1.1/jquery-3.1.1.js"></script>
<script type="text/javascript"
	src="${path}/bootstrap-3.3.5-dist/dist/js/bootstrap.js"></script>
<script type="text/javascript">
	function update(obj) {
		// console.log(obj.dataset.id);
		// console.log($(".dispatch_"+obj.dataset.id));
		for (var i = 0; i < $(".dispatch_" + obj.dataset.id).length; i++) {
			var textinnerHTML = $(".dispatch_" + obj.dataset.id)[i].innerHTML
			// console.log(textinnerHTML);
			$('input:text[name="dispatch_' + i + '"]').attr('value',
					textinnerHTML);
			if (i == $(".dispatch_" + obj.dataset.id).length - 1) {
				$('input:radio[name="dispatch_' + i + '"]').prop("checked",
						'false');
				$(
						'input:radio[name="dispatch_'
								+ i
								+ '"][value='
								+ $(".dispatch_" + obj.dataset.id)[i].dataset.val
								+ ']').prop('checked', 'true');
			}
		}
		$("#update_info").modal();
		$("#update_info .modal-footer button").attr('onclick',
				'saveDispatch(' + obj.dataset.id + ')');
	}
	
	function comfirmDispatch(obj){
		console.log(obj.dataset.href);
		console.log($("#dispatch_"+obj.dataset.id).val());
		var sid= $("#dispatch_"+obj.dataset.id).val();
		var dispatchHref = obj.dataset.href + '&sId=' + sid;
		console.log(dispatchHref);
		window.location.href = dispatchHref;
	}
</script>

</html>